package open.witype.filetiper.custom.Slidingmenu;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;

/**
 * Created by Typer on 2015/5/9 0009.
 * 滑动布局的基类
 */
public abstract class SlidingContentBase extends ViewGroup {

    public View mContent;

    public LayoutParams layoutParams;

    public static final int MIN_FLING_DISTATNCE = 25;

    public SlidingContentBase(Context context) {
        this(context, null);
    }

    public SlidingContentBase(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public void setContent(View v){
        if(mContent!=null)
            removeView(mContent);
        mContent = v;
        layoutParams = mContent.getLayoutParams();
        addView(mContent);
    }

    @Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        int width = r - l;
        int height = b -t;
        mContent.layout(0, 0, width, height);
    }
}
